package com.citycloud.edu.controller;

import com.citycloud.edu.service.IPositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author 陶肖寅
 * @version V1.0
 * <p>
 * date: 2020/10/31 9:59 下午
 * email:fromlx@126.com
 * @Copyright: 2020-2021 城云科技(中国)有限公司
 * </p>
 */
@RestController
public class PositionController {
    @Autowired
    private IPositionService service;

    // 测试页面
    @GetMapping({"/","/index"})
    public   String  indexPage(){
        return  "index";
    }
    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    @ResponseBody
    public List<Map<String,Object>> searchPosition(@PathVariable("keyword") String  keyword, @PathVariable("pageNo")int pageNo,
                                                   @PathVariable("pageSize")int  pageSize)throws IOException {
        List<Map<String,Object>> list = service.searchPos(keyword, pageNo, pageSize);
        return  list;
    }
    @RequestMapping("/importAll")
    @ResponseBody
    public   String  importAll(){
        try {
            service.importAll();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return  "success";
    }
}
